package sevletpojo;

import java.io.IOException;
import java.io.InputStream;

/**
 * @author 王瑞
 * @description:
 * @date 2020/3/1  18:45
 */
public class Request {

    private String method;

    private String url;

    private InputStream inputStream;


    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public Request(){}

    public Request(InputStream inputStream) throws IOException {
        this.inputStream = inputStream;
        int count = 0;
        while (count == 0){
            count = inputStream.available();
        }
        byte[] bytes = new byte[count];
        inputStream.read(bytes);
        String s = new String(bytes);
         /*GET /index.html HTTP/1.1*/
        String[] split = s.split("\\n");
        String[] split1 = split[0].split(" ");
        String s1 = split1[0];
        String s2 = split1[1];

        this.method = s1;
        this.url = s2;
    }
}
